<template>
	<view class="content" :style="`min-height: ${windowHeight}px`">
		<view class="rules-view">
			<view class="rules-content">
				<up-parse :content="content"></up-parse>
				<up-empty mode="data" text="暂无数据" icon="https://jqgh-public.yqfoodec.com/20250405/%E7%BB%84%2016@2x_53897.png" v-if="!content"></up-empty>
			</view>
		</view>
	</view>
</template>

<script>
	import { activityApi } from '@/api/activity/activity-app.js';
	import { UserAgreement, PrivacyAgreement } from '@/utils/agreement.js';
	
	export default {
		data() {
			return {
				content: '',
				windowHeight: 0
			}
		},
		onLoad(options) {// type:1健步走活动规则,2 随手拍，3知识竞赛规则,4用户协议，5隐私协议
			const id = options.id;
			if (options.type == '1') {
				this.getDetail(id);
			} else if (options.type == '2') {
				this.getRuleList(id)
			} else if (options.type == '3') {
				this.getKnowRule(id)
			} else {
				uni.setNavigationBarTitle({
					title: options.type == '5'?'隐私协议':'用户协议'
				})
				if (options.type == '4') {
					this.content = UserAgreement()
				} else {
					this.content = PrivacyAgreement()
				}
			}
			
			this.getsize()
		},
		methods: {
			getsize() {
				let that = this
				uni.getSystemInfo({
					success(res) {
					  that.windowHeight = res.windowHeight
					},
				})
			},
			// 健步走
			async getDetail(id){
				const result = await activityApi.getDetail(id);
				this.content = result.data.activityRule
			},
			// 随手拍
			async getRuleList(id) {
				const info = await activityApi.getSnapshotInfo(id)
				this.content = info.data.activityRule
			},
			// 答题 规则
			async getKnowRule(id) {
				const result = await activityApi.getCompetitionDetail(id);
				this.content = result.data.registrationNotes
			}
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		background-color: #d81e06;
	}
	.rules-view {
		padding: 30rpx;
		
		.rules-content {
			border-radius: 20rpx;
			background-color: #fff;
			min-height: 84vh;
			padding: 30rpx;
		}
	}
	
</style>